home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / CoreGateway / LetterLog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  5.7 KB  |  162 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        LetterLog.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __LETTERLOG__
  15. #define __LETTERLOG__
  16.  
  17. #ifndef    __DISKLOG__
  18. #include "DiskLog.h"
  19. #endif
  20.  
  21. #ifndef    __OCEOBJECTS__
  22. #include "OCEObjects.h"
  23. #endif
  24.  
  25. #ifndef    __LETTER__
  26. #include "Letter.h"
  27. #endif
  28.  
  29. #ifndef    __RECIPIENT__
  30. #include "Recipient.h"
  31. #endif
  32.  
  33. class TLetter;
  34. class TLetterLogEntry;
  35.  
  36. #pragma push
  37. #pragma segment LetterLog
  38.  
  39. /***********************************|****************************************/
  40.  
  41. class TLetterLog : public TDiskLog
  42. {
  43. public:        TLetterLog ( const TFileSpec&, TPurgeCriteria* = nil );
  44.     virtual    ~TLetterLog ();
  45.  
  46.     virtual    Boolean                    AddLetter ( const TLetter* );
  47.     virtual    TLetterLogEntry*        CreateLetterEntry ( EntryIndex );
  48.  
  49.     // use the iterators and enumerators below to access entries in a letter log
  50.     // else use the remaining public methods in TDiskLog, except for those made protected below
  51.  
  52. protected:
  53.  
  54.     virtual    TLogEntry*                ReconstructEntryFromInfoAtCurrentMark ();
  55.     virtual    Boolean                    AddEntry ( TLogEntry& );        // call AddLetterEntry instead
  56.     virtual    TLogEntry*                CreateEntry ( EntryIndex );        // call CreateEntry instead
  57. };
  58.  
  59. extern TLetterLog* gBovineLetterLog;
  60.  
  61. /***********************************|****************************************/
  62.  
  63. class TLetterLogEntry : public TLogEntry
  64. {
  65. public:        TLetterLogEntry ();
  66.             TLetterLogEntry ( const TLetter& );
  67.     virtual    ~TLetterLogEntry ();
  68.  
  69.     enum LetterStatus { kCompleted, kNotCompleted, kUnknown };
  70.  
  71.     virtual    Boolean                    WriteTo ( TAbstractFile& ) const;
  72.     virtual    Boolean                    ReadFrom ( TAbstractFile& );
  73.  
  74.     virtual    unsigned long            GetTextLength () const;
  75.     virtual    void                    GetText ( char* buffer, unsigned long maxBufferSize ) const;
  76.     virtual    char*                    CreateText () const;
  77.  
  78.     virtual    ostream&                operator >> ( ostream& ) const;
  79.  
  80.     friend class TLetterLogWindow ;
  81.  
  82. protected:    Boolean                    GetRecipientName ( const TLetter&, RecipientTypeSet type, unsigned short index, TRString& ) const;
  83.             Boolean                    GetSubject ( const TLetter&, TRString& ) const;
  84.             const char*                GetClass () const;    // all subclasses must override
  85.             LetterStatus            DetermineLetterStatus ( const TLetter& ) const;
  86.  
  87. private:    BLJLetterID             fID;
  88.             TRString                fSender;
  89.             TRString                fSubject;
  90.             BLJTime                 fTime;
  91.             LetterStatus            fStatus;
  92.             TRString                fMessage;
  93. };
  94.  
  95. /***********************************|****************************************/
  96.  
  97. class TLetterLogEnumerator
  98. {
  99. public:        TLetterLogEnumerator ( TLetterLog& );
  100.     virtual    ~TLetterLogEnumerator ();
  101.  
  102.             unsigned long            CountEntries () const;
  103.  
  104.             const TLetterLogEntry*    GetEntryByIndex ( unsigned long );
  105.             TLetterLogEntry*        AdoptEntryByIndex ( unsigned long );
  106.  
  107.             const TLetterLogEntry*    GetEntryByLogID ( unsigned long );
  108.             TLetterLogEntry*        AdoptEntryByLogID ( unsigned long );
  109.  
  110. private:    TLetterLogEnumerator ();
  111.             TLetterLogEnumerator&    operator = ( const TLetterLogEnumerator& );
  112.  
  113.             TDiskLogEnumerator        fImplementation;
  114. };
  115.  
  116. /***********************************|****************************************/
  117.  
  118. class TLetterLogIterator
  119. {
  120. public:        TLetterLogIterator ( TLetterLog& );
  121.     virtual    ~TLetterLogIterator ();
  122.  
  123.             const TLetterLogEntry*    GetFirstEntry ();
  124.             TLetterLogEntry*        AdoptFirstEntry ();
  125.  
  126.             const TLetterLogEntry*    GetNextEntry ();
  127.             TLetterLogEntry*        AdoptNextEntry ();
  128.  
  129.             const TLetterLogEntry*    GetLastEntry ();
  130.             TLetterLogEntry*        AdoptLastEntry ();
  131.  
  132.             const TLetterLogEntry*    GetPreviousEntry ();
  133.             TLetterLogEntry*        AdoptPreviousEntry ();
  134.  
  135. private:    TLetterLogIterator ( const TLetterLogIterator& );
  136.             TLetterLogIterator&        operator = ( const TLetterLogIterator& );
  137.  
  138.             TDiskLogIterator        fImplementation;
  139. };
  140.  
  141. /***********************************|****************************************/
  142.  
  143. inline unsigned long TLetterLogEnumerator::CountEntries () const { return fImplementation.CountEntries (); }
  144. inline const TLetterLogEntry* TLetterLogEnumerator::GetEntryByIndex ( unsigned long index ) { return (const TLetterLogEntry*) fImplementation.GetEntryByIndex ( index ); }
  145. inline TLetterLogEntry* TLetterLogEnumerator::AdoptEntryByIndex ( unsigned long index ) { return (TLetterLogEntry*) fImplementation.AdoptEntryByIndex ( index ); }
  146. inline const TLetterLogEntry* TLetterLogEnumerator::GetEntryByLogID ( unsigned long id ) { return (const TLetterLogEntry*) fImplementation.GetEntryByID ( id ); }
  147. inline TLetterLogEntry* TLetterLogEnumerator::AdoptEntryByLogID ( unsigned long id ) { return (TLetterLogEntry*) fImplementation.AdoptEntryByID ( id ); }
  148. inline const TLetterLogEntry* TLetterLogIterator::GetFirstEntry () { return (const TLetterLogEntry*) fImplementation.GetFirstEntry (); }
  149. inline TLetterLogEntry* TLetterLogIterator::AdoptFirstEntry () { return (TLetterLogEntry*) fImplementation.AdoptFirstEntry (); }
  150. inline const TLetterLogEntry* TLetterLogIterator::GetNextEntry () { return (const TLetterLogEntry*) fImplementation.GetNextEntry (); }
  151. inline TLetterLogEntry* TLetterLogIterator::AdoptNextEntry () { return (TLetterLogEntry*) fImplementation.AdoptNextEntry (); }
  152. inline const TLetterLogEntry* TLetterLogIterator::GetLastEntry () { return (const TLetterLogEntry*) fImplementation.GetLastEntry (); }
  153. inline TLetterLogEntry* TLetterLogIterator::AdoptLastEntry () { return (TLetterLogEntry*) fImplementation.AdoptLastEntry (); }
  154. inline const TLetterLogEntry* TLetterLogIterator::GetPreviousEntry () { return (const TLetterLogEntry*) fImplementation.GetPreviousEntry (); }
  155. inline TLetterLogEntry* TLetterLogIterator::AdoptPreviousEntry () { return (TLetterLogEntry*) fImplementation.AdoptPreviousEntry (); }
  156.  
  157. /***********************************|****************************************/
  158.  
  159. #pragma pop
  160.  
  161. #endif    // __LETTERLOG__
  162.